package com.kye.express.business.help.list;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

/**
 * 帮助 Fragment的Adapter
 * <p>
 * Created by SkyYu on 2018/01/9
 */
public class HelpFragmentPageAdapter extends FragmentPagerAdapter {

    private String[] titles;

    HelpFragmentPageAdapter(FragmentManager fm, String[] titles) {
        super(fm);
        this.titles = titles;
    }

    @Override
    public Fragment getItem(int position) {
        switch (position) {
            case 0:
                return HelpFragment.newInstance(HelpItemTypeModel.LUCKY_MONEY);
            case 1:
                return HelpFragment.newInstance(HelpItemTypeModel.BONUS);
            case 2:
                return HelpFragment.newInstance(HelpItemTypeModel.ACCOUNT_SECURITY);
            case 3:
                return HelpFragment.newInstance(HelpItemTypeModel.HELP);
            default:
                throw new IllegalArgumentException("position error");
        }
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }

    @Override
    public int getCount() {
        return titles.length;
    }
}